package com.ptswitch.material.pages.security;

import java.util.List;

import org.apache.tapestry5.EventConstants;
import org.apache.tapestry5.annotations.OnEvent;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SetupRender;
import org.apache.tapestry5.ioc.annotations.Inject;

import com.ptswitch.material.model.security.Role;
import com.ptswitch.material.pages.base.PageBase;
import com.ptswitch.material.service.RoleService;
import com.ptswitch.material.util.security.PermissionUtil;

public class ListRole extends PageBase {
    @Inject
    private RoleService roleSer;
    //
    @Property
    private List<Role> roleList;
    @Property
    private List<Role> relateRoleList;

    @OnEvent(value = EventConstants.ACTIVATE)
    Object init() {
        checkPermitted(PermissionUtil.RoleList);
        return null;
    }

    @SetupRender
    Object display() {
        roleList = roleSer.findNormalRoles();
        relateRoleList = roleSer.findRelateRoles();
        return null;
    }

}
